 <include file="public:header"/>
<link rel="stylesheet" type="text/css" href="layui/css/layui.css">
<style type="text/css">  
/* start 分页样式 */

.pageers{
    overflow:hidden;
/*    margin:10px 0 50px 100px;*/
    margin-top: -40px;
    float:right;
}

.pageers ul a,.pageers ul span{
    float:left;
    display:inline-block;
    padding: 0 13px;
    height:30px;
    width:auto;
    border:1px solid #DDDDDD;
    border-radius: 4px;
    background:#fff;
    text-align:center;
    line-height:30px;
    margin-right:5px;
    font-family: "microsoft yahei" simhei sans-serif;
    color:#7d7d7d;
}

.pageers ul a:hover{
    background:#337AB7;
    color:#fff;
    text-decoration:none;
}

.pageers ul span.current{
    background: #337AB7;
    color:#fff;
}


.pageers ul a:first,.pageers ul a:last{
    float:right;
    display:inline-block;
    width:30px;
    height:30px;
    border-radius:50%;
    text-align:center;
    line-height:30px;
    margin-right:10px;
    font-family: "microsoft yahei" simhei sans-serif;
}

#pageTips {
padding-top: 40px;
}
.loadimg{
    display: inline-block;
    width: 15px;
    height: 15px;
    position: relative;
    top: 3px;
    background: url(../images/5-121204193R7.gif) no-repeat 0 0;
    background-size: 100% 100%;
}
.resetdiv{
    width: 400px;
    padding: 30px;
    background: #fff;
    margin: 80px auto 0;
}
.resetdiv label{
    display: block;
    padding: 6px 0;
    width: 300px;
    margin: 20px auto;
}
.resetdiv label span{
    display: inline-block;
    width: 100px;
    font-size: 16px;
    height: 30px;
    line-height: 30px;
}
.resetdiv label input{
    display: inline-block;
    width: 200px;
    height: 30px;
    line-height: 30px;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    -ms-border-radius: 2px;
    -o-border-radius: 2px;
    padding-left: 10px;
}
.resetdiv p{
    width: 300px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    background: #fe504f;
    color: #fff;
    border-radius: 4px;
    -webkit-border-radius: 4px;
    -ms-border-radius: 4px;
    -o-border-radius: 4px;
    font-size: 16px;
    margin: 30px auto;
}
/* end 分页样式 */
</style>
<!-- Page -->

    <div class="page animsition" style="animation-duration: 800ms; opacity: 1;">
        <div class="page-content padding-30 container-fluid">
            <div class="resetdiv">
                <input type="hidden" id="orderid" value="{:I('get.orderid')}">
                <label>
                    <span>新密码：</span><input onblur="loginpass(this)" type="password" id="newpass" placeholder="请输入新密码">
                </label>
                <label>
                    <span>确认密码：</span><input onblur="surepass(this)" type="password" id="surepass" placeholder="请输入确认密码">
                </label>
                <p class="submitP" onclick="submits()">确认提交</p>      
            </div>
        </div>
    </div>

    <!--弹窗-创建云服务器-->
    <!--创建云主机弹窗 End-->
    <!--开机弹窗 -->
    <script src="layui/layui.js"></script>
    <script type="text/javascript">
      var orderid = $("#orderid").val();
        // 验证输入的登录密码与确认密码是否一致
      function surepass(id){
        var surepass = $(id).val();
        var loginpass = $(id).parent().siblings('label').find('#newpass').val();
        // alert(loginpass.match(str));
        if(surepass != loginpass){
          layui.use('layer', function(){
                var layer = layui.layer;
                layer.msg('您2次输入的密码不一致，请重新输入');
              });
        }
        
      }
        function loginpass(id){
            var loginpass = $(id).val();
            var str = /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\\W_!@#$%^&*`~()-+=]+$)(?![0-9\\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\\W_!@#$%^&*`~()-+=]{8,30}$/;
            if(!loginpass.match(str)){
              layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.msg('您输入的密码格式不正确，请重新输入');
                  });
            }
      }
        function submits(){
            var newpass = $('#newpass').val();
            var surepass = $('#surepass').val();
            if(newpass != '' && surepass != '' && newpass == surepass){
                $.ajax({
                    url: "{:U('home/console/passinfo')}",
                    type: 'post',
                    dataType: 'json',
                    data:{
                        password: newpass,
                        orderid: orderid
                    },
                    success: function(res){
                        if(res == 1){
                            layui.use('layer', function(){
                                var layer = layui.layer;
                                layer.msg('设置成功');
                                location.href="{:U('home/console/yun')}";
                              });
                        }else{
                            layui.use('layer', function(){
                                var layer = layui.layer;
                                layer.msg('设置失败');
                            });
                        }
                    }
                })
            }else{
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.msg('请正确填写您的密码');
                  });
            }
        }
    </script>
<!-- End Page -->

 <include file="public:footer"/>